
package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;

/**
 *
 * @author Thomas
 */
public class CtrlInvoice 
{
    
    private Invoice invoice;
    
    /**
     * Creates a new instance of CtrlInvoice
     */
    public CtrlInvoice()
    {
    
    }
    
    public ArrayList findAllInvoices()
    {
      IFDBInvoice dbInv = new DBInvoice();
      ArrayList allInvoices = new ArrayList();
      allInvoices = dbInv.getAllInvoices();
      return allInvoices;
    }
    
      public Invoice findInvoice(int invoiceNo)
    {
        IFDBInvoice dbInv = new DBInvoice();
        return dbInv.findInvoice(invoiceNo);
    }
      
    public ArrayList searchInvoiceDate(String date)
    {
        IFDBInvoice dbInv = new DBInvoice();
        ArrayList dateInvoices = new ArrayList();
        dateInvoices = dbInv.searchInvoiceDate(date);
        return dateInvoices;
    }
    
    
     
    public void insertInvoice(Invoice invoice)
    {
         IFDBInvoice dbInv = new DBInvoice();
         dbInv.insertInvoice(invoice);
    }
    
    
    public int updateInvoice(String paymentDate, double amount, String date)
    {
         IFDBInvoice dbInv = new DBInvoice();
         Invoice inv = new Invoice();
         inv.setPaymentDate(paymentDate);
         inv.setAmount(amount);
         inv.setDate(date);
          
         return  dbInv.updateInvoice(inv);
     }
      
     public void deleteInvoice(int invoiceNo)
     {
         IFDBInvoice dbInv = new DBInvoice();
         dbInv.deleteInvoice(invoiceNo);
     }
    
}
